//
//  PatientHealthInfoCell.m
//  Doctor
//
//  Created by 阳光 on 16/9/7.
//  Copyright © 2016年 阳光. All rights reserved.
//

#import "PatientHealthInfoCell.h"

@interface PatientHealthInfoCell ()

// 上次月经时间
@property(nonatomic,strong)UILabel *lastTimeLabel;

@property(nonatomic,strong)UIView *lastTimeLine;

// 月经第2-3天最近一次激素检查
@property(nonatomic,strong)UIButton *checkArrowBtn;

@property(nonatomic,strong)UIView *checkLine;

// 月经天数
@property(nonatomic,strong)UILabel *dayLabel;

@property(nonatomic,strong)UIView *dayLine;

// 月经周期
@property(nonatomic,strong)UILabel *weekLabel;

@property(nonatomic,strong)UIView *weekLine;

// 月经量
@property(nonatomic,strong)UILabel *numberLabel;

@property(nonatomic,strong)UIView *numberLine;

// 月经第2-3天左卵巢基础卵数量
@property(nonatomic,strong)UIButton *leftNumberBtn;

@property(nonatomic,strong)UIView *leftNumberLine;

// 月经第2-3天右卵巢基础卵数量
@property(nonatomic,strong)UIButton *rightNumberBtn;

@property(nonatomic,strong)UIView *rightNumberLine;

// 子宫内膜厚度
@property(nonatomic,strong)UILabel *widthLabel;

@property(nonatomic,strong)UIView *widthLine;

// 是否有子宫肌瘤
@property(nonatomic,strong)UILabel *sickLabel;


@end

@implementation PatientHealthInfoCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor=WhiteColor;
        
        self.lastTimeLabel.font=Font_Number(16);
        self.lastTimeLabel.hidden=NO;
        
        self.checkArrowBtn.hidden=NO;
        self.checkLine.hidden=NO;
        
        self.dayLabel.font=Font_Number(16);
        self.dayLine.hidden=NO;
        
        self.weekLabel.font=Font_Number(16);
        self.weekLine.hidden=NO;
        
        self.numberLabel.font=Font_Number(16);
        self.numberLine.hidden=NO;
        
        self.leftNumberBtn.hidden=NO;
        self.leftNumberLine.hidden=NO;
        
        self.rightNumberBtn.hidden=NO;
        self.rightNumberLine.hidden=NO;
        
        self.widthLabel.font=Font_Number(16);
        self.widthLine.hidden=NO;
        
        self.sickLabel.font=Font_Number(16);

    };
    return self;
}

// lastTimeLabel
-(UILabel *)lastTimeLabel
{
    if (!_lastTimeLabel) {
        _lastTimeLabel=[self getLabelWithText:@"2016年08月12日" font:Font_Number(16) textColor:Color333333 textAlignment:NSTextAlignmentRight lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:_lastTimeLabel];
        
        UILabel *leftLastTimeLabel=[self getLabelWithText:NSLocalizedString(@"Last menstruation", nil) font:Font_Number(16) textColor:Color666666 textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:leftLastTimeLabel];
        
        [leftLastTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.mas_equalTo(kmargin);
        }];
        
        [_lastTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(kmargin);
            make.right.mas_equalTo(-kmargin);
        }];
    }
    return _lastTimeLabel;
}

-(UIView *)lastTimeLine
{
    if (!_lastTimeLine) {
        _lastTimeLine=[UIView new];
        _lastTimeLine.backgroundColor=MAIN_BACK_COLOR;
        [self.contentView addSubview:_lastTimeLine];
        [_lastTimeLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.lastTimeLabel.mas_bottom).offset(kmargin);
            make.left.mas_equalTo(kmargin);
            make.right.mas_equalTo(-kmargin);
            make.height.mas_equalTo(1);
        }];
    }
    return _lastTimeLine;
}

// checkArrowBtn
-(UIButton *)checkArrowBtn
{
    if (!_checkArrowBtn) {
        _checkArrowBtn=[UIButton new];
        [_checkArrowBtn setImage:[UIImage imageNamed:@"cell_arrow"] forState:0];
        [self.contentView addSubview:_checkArrowBtn];
        //@"月经第2-3天最近一次激素检查"
        UILabel *leftCheckLabel=[self getLabelWithText:NSLocalizedString(@"Hormone Report", nil) font:Font_Number(16) textColor:Color666666 textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:leftCheckLabel];
        
        [leftCheckLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(kmargin);
            make.top.mas_equalTo(self.lastTimeLine.mas_bottom).offset(kmargin);
        }];
        
        [_checkArrowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.lastTimeLine.mas_bottom).offset(kmargin);
            make.right.mas_equalTo(-kmargin);
            make.size.mas_equalTo(CGSizeMake(kmargin*5/2,kmargin*5/2));
        }];
        [_checkArrowBtn addTarget:self action:@selector(checkArrowBtnEvent) forControlEvents:UIControlEventTouchUpInside];
    }
    return _checkArrowBtn;
}

-(void)checkArrowBtnEvent
{
    if ([self.delegate respondsToSelector:@selector(checkArrowBtnEvent)])
    {
        [self.delegate checkArrowBtnEvent];
    }
}

-(UIView *)checkLine
{
    if (!_checkLine) {
        _checkLine=[UIView new];
        _checkLine.backgroundColor=MAIN_BACK_COLOR;
        [self.contentView addSubview:_checkLine];
        [_checkLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.checkArrowBtn.mas_bottom).offset(kmargin);
            make.left.mas_equalTo(kmargin);
            make.right.mas_equalTo(-kmargin);
            make.height.mas_equalTo(1);
        }];
    }
    return _checkLine;
}

// dayLabel
-(UILabel *)dayLabel
{
    if (!_dayLabel) {
        _dayLabel=[self getLabelWithText:@"5" font:Font_Number(16) textColor:Color333333 textAlignment:NSTextAlignmentRight lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:_dayLabel];
        
        UILabel *leftDayLabel=[self getLabelWithText:NSLocalizedString(@"Menstruation days", nil) font:Font_Number(16) textColor:Color666666 textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:leftDayLabel];
        
        [leftDayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(kmargin);
            make.top.mas_equalTo(self.checkLine.mas_bottom).offset(kmargin);
        }];
        
        [_dayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.checkLine.mas_bottom).offset(kmargin);
            make.right.mas_equalTo(-kmargin);
        }];
    }
    return _dayLabel;
}

-(UIView *)dayLine
{
    if (!_dayLine) {
        _dayLine=[UIView new];
        _dayLine.backgroundColor=MAIN_BACK_COLOR;
        [self.contentView addSubview:_dayLine];
        [_dayLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.dayLabel.mas_bottom).offset(kmargin);
            make.left.mas_equalTo(kmargin);
            make.right.mas_equalTo(-kmargin);
            make.height.mas_equalTo(1);
        }];
    }
    return _dayLine;
}

// weekLabel
-(UILabel *)weekLabel
{
    if (!_weekLabel) {
        _weekLabel=[self getLabelWithText:@"29" font:Font_Number(16) textColor:Color333333 textAlignment:NSTextAlignmentRight lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:_weekLabel];
        
        UILabel *leftWeekLabel=[self getLabelWithText:NSLocalizedString(@"Menstrual cycle", nil) font:Font_Number(16) textColor:Color666666 textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:leftWeekLabel];
        
        [leftWeekLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(kmargin);
            make.top.mas_equalTo(self.dayLine.mas_bottom).offset(kmargin);
        }];
        
        [_weekLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.dayLine.mas_bottom).offset(kmargin);
            make.right.mas_equalTo(-kmargin);
        }];
    }
    return _weekLabel;
}

-(UIView *)weekLine
{
    if (!_weekLine) {
        _weekLine=[UIView new];
        _weekLine.backgroundColor=MAIN_BACK_COLOR;
        [self.contentView addSubview:_weekLine];
        [_weekLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.weekLabel.mas_bottom).offset(kmargin);
            make.left.mas_equalTo(kmargin);
            make.right.mas_equalTo(-kmargin);
            make.height.mas_equalTo(1);
        }];
    }
    return _weekLine;
}

// numberLabel
-(UILabel *)numberLabel
{
    if (!_numberLabel) {
        _numberLabel=[self getLabelWithText:@"较多" font:Font_Number(16) textColor:Color333333 textAlignment:NSTextAlignmentRight lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:_numberLabel];
        
        UILabel *leftNumberLabel=[self getLabelWithText:NSLocalizedString(@"Menstrual volume", nil) font:Font_Number(16) textColor:Color666666 textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:leftNumberLabel];
        
        [leftNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(kmargin);
            make.top.mas_equalTo(self.weekLine.mas_bottom).offset(kmargin);
        }];
        
        [_numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.weekLine.mas_bottom).offset(kmargin);
            make.right.mas_equalTo(-kmargin);
        }];
    }
    return _numberLabel;
}

-(UIView *)numberLine
{
    if (!_numberLine) {
        _numberLine=[UIView new];
        _numberLine.backgroundColor=MAIN_BACK_COLOR;
        [self.contentView addSubview:_numberLine];
        [_numberLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.numberLabel.mas_bottom).offset(kmargin);
            make.left.mas_equalTo(kmargin);
            make.right.mas_equalTo(-kmargin);
            make.height.mas_equalTo(1);
        }];
    }
    return _numberLine;
}

// leftNumberBtn
-(UIButton *)leftNumberBtn
{
    if (!_leftNumberBtn) {
        _leftNumberBtn=[UIButton new];
        [_leftNumberBtn setImage:[UIImage imageNamed:@"cell_arrow"] forState:0];
        [self.contentView addSubview:_leftNumberBtn];
        
        UILabel *leftNumberLabel=[self getLabelWithText:NSLocalizedString(@"Basal left follicular number", nil) font:Font_Number(16) textColor:Color666666 textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:leftNumberLabel];
        
        [leftNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(kmargin);
            make.top.mas_equalTo(self.numberLine.mas_bottom).offset(kmargin);
        }];
        
        [_leftNumberBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.numberLine.mas_bottom).offset(kmargin);
            make.right.mas_equalTo(-kmargin);
            make.size.mas_equalTo(CGSizeMake(kmargin*5/2,kmargin*5/2));
        }];
        [_leftNumberBtn addTarget:self action:@selector(leftNumberBtnEvent) forControlEvents:UIControlEventTouchUpInside];
    }
    return _leftNumberBtn;
}

-(void)leftNumberBtnEvent
{
    if ([self.delegate respondsToSelector:@selector(leftNumberBtnEvent)])
    {
        [self.delegate leftNumberBtnEvent];
    }
}

-(UIView *)leftNumberLine
{
    if (!_leftNumberLine) {
        _leftNumberLine=[UIView new];
        _leftNumberLine.backgroundColor=MAIN_BACK_COLOR;
        [self.contentView addSubview:_leftNumberLine];
        [_leftNumberLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.leftNumberBtn.mas_bottom).offset(kmargin);
            make.left.mas_equalTo(kmargin);
            make.right.mas_equalTo(-kmargin);
            make.height.mas_equalTo(1);
        }];
    }
    return _leftNumberLine;
}

// rightNumberBtn
-(UIButton *)rightNumberBtn
{
    if (!_rightNumberBtn) {
        _rightNumberBtn=[UIButton new];
        [_rightNumberBtn setImage:[UIImage imageNamed:@"cell_arrow"] forState:0];
        [self.contentView addSubview:_rightNumberBtn];
        
        UILabel *rightNumberLabel=[self getLabelWithText:NSLocalizedString(@"Basal right follicular number", nil) font:Font_Number(16) textColor:Color666666 textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:rightNumberLabel];
        
        [rightNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(kmargin);
            make.top.mas_equalTo(self.leftNumberLine.mas_bottom).offset(kmargin);
        }];
        
        [_rightNumberBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.leftNumberLine.mas_bottom).offset(kmargin);
            make.right.mas_equalTo(-kmargin);
            make.size.mas_equalTo(CGSizeMake(kmargin*5/2,kmargin*5/2));
        }];
        [_rightNumberBtn addTarget:self action:@selector(rightNumberBtnEvent) forControlEvents:UIControlEventTouchUpInside];
    }
    return _rightNumberBtn;
}

-(void)rightNumberBtnEvent
{
    if ([self.delegate respondsToSelector:@selector(rightNumberBtn)])
    {
        [self.delegate rightNumberBtnEvent];
    }
}

-(UIView *)rightNumberLine
{
    if (!_rightNumberLine) {
        _rightNumberLine=[UIView new];
        _rightNumberLine.backgroundColor=MAIN_BACK_COLOR;
        [self.contentView addSubview:_rightNumberLine];
        [_rightNumberLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.rightNumberBtn.mas_bottom).offset(kmargin);
            make.left.mas_equalTo(kmargin);
            make.right.mas_equalTo(-kmargin);
            make.height.mas_equalTo(1);
        }];
    }
    return _rightNumberLine;
}


// widthLabel
-(UILabel *)widthLabel
{
    if (!_widthLabel) {
        _widthLabel=[self getLabelWithText:@"8.9" font:Font_Number(16) textColor:Color333333 textAlignment:NSTextAlignmentRight lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:_widthLabel];
        
        UILabel *leftWidthLabel=[self getLabelWithText:NSLocalizedString(@"Endomertrial thickness", nil) font:Font_Number(16) textColor:Color666666 textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:leftWidthLabel];
        
        [leftWidthLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(kmargin);
            make.top.mas_equalTo(self.rightNumberLine.mas_bottom).offset(kmargin);
        }];
        
        [_widthLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.rightNumberLine.mas_bottom).offset(kmargin);
            make.right.mas_equalTo(-kmargin);
        }];
    }
    return _widthLabel;
}

-(UIView *)widthLine
{
    if (!_widthLine) {
        _widthLine=[UIView new];
        _widthLine.backgroundColor=MAIN_BACK_COLOR;
        [self.contentView addSubview:_widthLine];
        [_widthLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.widthLabel.mas_bottom).offset(kmargin);
            make.left.mas_equalTo(kmargin);
            make.right.mas_equalTo(-kmargin);
            make.height.mas_equalTo(1);
        }];
    }
    return _widthLine;
}

// sickLabel
-(UILabel *)sickLabel
{
    if (!_sickLabel) {
        _sickLabel=[self getLabelWithText:@"无" font:Font_Number(16) textColor:Color333333 textAlignment:NSTextAlignmentRight lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:_sickLabel];
        //@"是否有子宫肌瘤"
        UILabel *leftSickLabel=[self getLabelWithText:NSLocalizedString(@"Uterine fibroid", nil) font:Font_Number(16) textColor:Color666666 textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:leftSickLabel];
        
        [leftSickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(kmargin);
            make.top.mas_equalTo(self.widthLine.mas_bottom).offset(kmargin);
        }];
        
        [_sickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.widthLine.mas_bottom).offset(kmargin);
            make.right.mas_equalTo(-kmargin);
        }];
    }
    return _sickLabel;
}

-(void)setPatientInfoDic:(NSDictionary *)patientInfoDic
{
    _patientInfoDic=patientInfoDic;
    
    _lastTimeLabel.text=patientInfoDic[@"sperm_date"];
    
    
    _dayLabel.text=patientInfoDic[@"menstrual_days"];
    
    _weekLabel.text=patientInfoDic[@"menstrual_cycle"];
    
    _numberLabel.text=patientInfoDic[@"menstrual_amount"];
    
    _widthLabel.text=patientInfoDic[@"endome_thick"];

//    _sickLabel.text=patientInfoDic[@""];
    
    
    _sickLabel.text=@"无";
}

@end
